<%@ page language="java" contentType="text/html;charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
    <jsp:include page="../common/common.jsp"/>
</head>
<body class="page-header-fixed">
<jsp:include page="../common/header.jsp"/>
<div class="clearfix">
</div>
<div class="page-container">
    <div class="page-sidebar-wrapper">
        <jsp:include page="../common/menu.jsp"/>
    </div>
    <div class="page-content-wrapper">
        <div class="page-content">
            <div class="row">
                <div class="col-md-12">
                    <form class="form-horizontal form-row-seperated" action="${path}/friendLink/update">
                        <div class="portlet box purple">
                            <div class="portlet-title">
                                <div class="caption">
                                    <i class="fa fa-shopping-cart"></i>网站基本信息
                                </div>
                                <div class="actions btn-set">
                                    <a href="javascript:history.go(-1);" class="btn default"><i
                                            class="fa fa-angle-left"></i> 返回</a>
                                    <a href="javascript:location.reload();" class="btn green"><i
                                            class="fa fa-reply"></i> 重置</a>
                                    <button type="button" id="btnSave" class="btn blue"><i class="fa fa-check"></i> 保存
                                    </button>
                                </div>
                            </div>
                            <div class="portlet-body">
                                <div class="tabbable">
                                    <div class="tab-content no-space">
                                        <div class="tab-pane active" id="tab_general">
                                            <div class="form-body">
                                                <%-- <div class="form-group">
                                                    <label class="col-md-2 control-label">网站状态:
                                                       <!--  <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <select name="status" class="form-control">
                                                            <option value="0"
                                                                    <c:if test="${data.status==0}">selected="selected" </c:if>>
                                                                正常
                                                            </option>
                                                            <option value="1"
                                                                    <c:if test="${data.status==1}">selected="selected" </c:if>>
                                                                禁用
                                                            </option>
                                                        </select>
                                                    </div>
                                                </div> --%>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">网站名称:
                                                        <!-- <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="name" name="name"
                                                               class="form-control measure-input" value="${data.name}"/>
                                                    </div>
                                                    <div class="col-md-5">
                                                        &nbsp;可输入<b><span id="title_len">80</span></b> 个字符
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">网址:
                                                        <!-- <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="url" name="url"
                                                               class="form-control measure-input" value="${data.url}"/>
                                                    </div>
                                                </div>
                                                
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">首页关键词:
                                                        <!-- <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="keyword" name="keyword"
                                                               class="form-control measure-input" value="${data.keyword}"/>
                                                    </div>
                                                </div>
                                                 <div class="form-group">
                                                    <label class="col-md-2 control-label">客服QQ:
                                                        <!-- <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="customqq" name="customqq"
                                                               class="form-control measure-input" value="${data.customqq}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">电话:
                                                        <!-- <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="phone" name="phone"
                                                               class="form-control measure-input" value="${data.phone}"/>
                                                    </div>
                                                    <div class="col-md-5">
                                                        &nbsp;多个电话中间用&lt;br&gt;隔开
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">传真:
                                                        <!-- <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="phone" name="fax"
                                                               class="form-control measure-input" value="${data.fax}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">邮箱:
                                                        <!-- <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="phone" name="email"
                                                               class="form-control measure-input" value="${data.email}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">地址:
                                                        <!-- <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="phone" name="address"
                                                               class="form-control measure-input" value="${data.address}"/>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">备案编号:
                                                       <!--  <span class="required">*</span> -->
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="recordnum" name="recordnum"
                                                               class="form-control measure-input" value="${data.recordnum}"/>
                                                    </div>
                                                </div>
                                                <%-- <div class="form-group">
                                                    <label class="col-md-2 control-label">备案连接:
                                                        <span class="required">*</span>
                                                    </label>

                                                    <div class="col-md-5">
                                                        <input type="text" id="recordurl" name="recordurl"
                                                               class="form-control measure-input" value="${data.recordurl}"/>
                                                    </div>
                                                </div> --%>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">logo图片:</label>

                                                    <div class="col-md-8">
                                                        <div class="fileinput fileinput-new" data-provides="fileinput">
                                                            <div class="fileinput-new thumbnail"
                                                                 style="width: 300px; height: 150px;">
                                                                <img src="${data.imgUrl}">
                                                            </div>&nbsp;该图片显示在网站的logo位置 和 后台管理的登录页面
                                                            <div class="fileinput-preview fileinput-exists thumbnail"
                                                                 style="max-width: 300px; max-height: 150px;">
                                                            </div>
                                                            <div>
                                                                <span class="btn default btn-file">
                                                                    <span class="fileinput-new">选择图片</span>
                                                                    <span class="fileinput-exists">修改图片</span>
                                                                    <input type="file" id="file" name="file"/>
                                                                </span>
                                                                <a href="#" class="btn default fileinput-exists" data-dismiss="fileinput">移除图片</a>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">网站描述:
                                                    </label>
                                                    <div class="col-md-8">
                                                        <textarea cols="60" id="remark" name="remark" rows="5" style="border: 1px solid #e5e5e5;">${data.remark}</textarea>
                                                    </div>
                                                </div>
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">Meta信息:
                                                    </label>
                                                    <div class="col-md-8">
                                                        <textarea placeholder="用于第三方放置标识进行网站身份验证" cols="60" id="meta" name="meta" rows="5" style="border: 1px solid #e5e5e5;">${data.meta}</textarea>
                                                    </div>
                                                </div>
                                               
                                                <div class="form-group">
                                                    <label class="col-md-2 control-label">网站底部:
                                                    </label>
                                                    <div class="col-md-8">
                                                        <input id="footerMessage" type="hidden" name="footerMessage">
                                                        <script id="editor" type="text/plain" style="height:500px;">${data.footerMessage}</script>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="portlet-title">
                                <div class="actions btn-set">
                                    <a href="javascript:history.go(-1);" class="btn default"><i
                                            class="fa fa-angle-left"></i> 返回</a>
                                    <a href="javascript:location.reload();" class="btn green"><i
                                            class="fa fa-reply"></i> 重置</a>
                                    <button type="button" id="btnSave" class="btn blue"><i class="fa fa-check"></i> 保存
                                    </button>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" id="id" name="id" value="${data.id}">
                        <input type="hidden" id="imgUrl" name="imgUrl"  value="${data.imgUrl}"/>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<jsp:include page="../common/footer.jsp"/>
<script type="text/javascript" src="${path}/assets/plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<script type="text/javascript" src="${path}/assets/scripts/biz/ajaxfileupload.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="${path}/assets/plugins/ueditor/lang/zh-cn/zh-cn.js"></script>
<script>
    jQuery(document).ready(function () {
    	UE.getEditor('editor');
        $("button[id='btnSave']").click(function () {
        	 var context = UE.getEditor('editor').getContent();
        	 $("#footerMessage").val(context);
        	/* if($("#status").val()==""){
        		alert("网站状态不能为空!");
                return;
        	}else if($("#name").val()==""){
        		alert("网站名称不能为空!");
                return;
        	}else if($("#url").val()==""){
        		alert("网址不能为空!");
                return;
        	}else if($("#keyword").val()==""){
        		alert("首页关键词不能为空!");
                return;
        	}else if($("#customqq").val()==""){
        		alert("客服QQ不能为空!");
                return;
        	}else if($("#recordnum").val()==""){
        		alert("备案编号不能为空!");
                return;
        	}else{ */
	            ajaxFileUpload(function () {
	                App.ajax(_path + "/website/save", $("form").serialize(), function (data) {
	                    if (data.statusCode == 200) {
	                        App.bubble(200, "网站基本信息更新成功！");
	                        window.setTimeout(function(){
		                        window.location.href = _path + "/website/index";
	                        },400); 
	                    } else {
	                        App.bubble(500, "保存网站基本信息失败！");
	                    }
	                });
	            });
           /*  } */
        });
    });
    function ajaxFileUpload(callback) {
        if (!$("#file").val()) {
            callback();
            return;
        }
        $.ajaxFileUpload({
            url: '${path}/conf/upload',
            secureuri: false,
            fileElementId: 'file',
            dataType: 'json',
            success: function (data, status) {
                switch (data.statusCode) {
                    case 200 :
                        $("#imgUrl").val(data.uri);
                        callback();
                        break;
                    case 500 :
                        alert(data.info);
                        break;
                }
            }
        });
        return false;
    }
</script>
</body>
</html>
